<template>
	<view class="content" v-if="show==1">
		<image class="beijing" :src="site.b" mode="widthFix"></image>
		<view class="hongbao">
			<image class="hb" :src="site.by" mode="widthFix"></image>
			<view class="hb3"><text>￥</text>{{money}}</view>
			<view class="hb4">新人红包</view>
		</view>
		<image class="jieshou" @click="login" v-if="uid==0" src="../../static/images/jie.png" mode="widthFix"></image>
		<view class="yijie" v-if="uid>0">您已接受邀请，奖励尽快使用噢</view>
		<image class="jieshou" v-if="uid>0" @click="shiyong" style="margin-top: 20px;" src="../../static/images/shi.png" mode="widthFix"></image>
		<!--<view class="tishi">
					<view class="tishi2">精选课程</view>
					<view class="tishi4">
						<view class="goods4" v-for="(g,index) in goods" @click="gurl" :data-id="g.id">
							<image class="goods4-1" :src="g.image" mode="aspectFit"></image>
							<view class="goods4-2">
								<view class="goods4-3">{{g.title}}</view>
								<view class="goods4-7">
									<text v-if="g.nid>0">{{g.nianji}}</text>
									<text v-if="g.cid>0">{{g.cate}}</text>
								</view>
								<view class="goods4-4">
									<text class="goods4-5">￥{{g.price}}</text>
									<text class="goods4-6">已售{{g.sales}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>-->
	</view>
</template>

<script>
	var app=getApp();
	export default {
		data() {
			return {
				pid:0,
				uid:0,
				money:0,
				show:0,
				user:[],
				goods:[],
				site:[]
			}
		},
		onLoad(op) {
			if(app.isBlank(op.uid)==false){
				this.pid=op.uid;
			}else{
				uni.switchTab({
				    url: '/pages/index/index'
				});
				return false;
			}
			const uid = uni.getStorageSync('uid');
			if(app.isBlank(uid)==false){
				this.uid=uid;
			}
			
			this.getdata();
		},
		methods: {
			getdata(){
				var that=this;
				uni.showLoading({
				    title: '数据加载中'
				});
				uni.request({
				    url: app.globalData.url+"index/yaoqing",
					method:"POST",
					dataType:"json",
					header: {
					    'content-type': 'application/x-www-form-urlencoded'
					},
				    data: {uid:that.uid},
				    success: (res) => {
						uni.hideLoading();
						if(res.data.code!=1){
							app.error_msg(res.data.msg);
						}
						if(that.uid>0){
							that.money=res.data.data.user.yq_money2;
						}else{
							that.money=res.data.data.site.yhq_money2;
						}
						that.site=res.data.data.site
						that.user=res.data.data.user
						//that.goods=res.data.data.goods
						that.show=1;
				    }
				});
			},
			login(){
				uni.navigateTo({
				    url: '/pages/login/login?uid='+this.pid
				});
			},
			shiyong(){
				uni.reLaunch({
				    url: '/pages/goods/index'
				});
			},
			gurl(e){
				var id=e.currentTarget.dataset.id;
				uni.navigateTo({
				    url: '/pages/goods/detail?id='+id
				});
			}
		}
	}
</script>

<style>
	.goods4-7 text{color:#666;margin-right: 10px;}
	.goods4-7{width:100%;height:25px;line-height: 25px;overflow: hidden;}
	.goods4-6{color:#666;float: right;}
	.goods4-5{font-size: 1rem;color:#fe2424;float: left;}
	.goods4-4{width:100%;height:30px;line-height: 30px;overflow: hidden;}
	.goods4-3{width:100%;height:25px;line-height: 25px;overflow: hidden;font-weight: 600;font-size: 0.9rem;}
	.goods4-2{width:100%;height:80px;flex: 1;}
	.goods4-1{width:120px;height:80px;border-radius: 5px;margin-right: 10px;}
	.goods4{width:100%;padding: 10px 0px;display: flex;}
	.yijie{width:100%;text-align: center;color:#bb3804;font-size: 0.9rem;margin-top: 30px;}
	.jieshou{width:80%;margin: 0px auto;margin-top: 30px;margin-bottom: 20px;z-index:9999;}
	.meiyou{width:100%;text-align: center;margin: 40px 0px;color:#999;}
	.tishi5-2{width:30px;height:50px;line-height: 50px;color:#fa1d2c;font-size: 1rem;text-align: right;}
	.tishi5-1-2{width:100%;height:20px;line-height:16px;overflow: hidden;color:#999;}
	.tishi5-1-1{width:100%;height:30px;line-height:32px;font-size: 0.95rem;overflow: hidden;}
	.tishi5-1{width:100%;flex: 1;}
	.tishi5 image{width:50px;height:50px;border-radius: 50%;margin-right: 8px;}
	.tishi5{width:100%;height:50px;display: flex;padding: 10px 0px;}
	.tishi4{width:94%;padding: 0 3%;}
	.tishi3{padding: 10px;line-height: 25px;color:#666;}
	.tishi2{width:100%;height:40px;line-height: 40px;text-align: center;color:#fff;background-color: #fe4b23;}
	.tishi{width:94%;margin: 20px 3%;background-color: #fff;border-radius: 5px;overflow: hidden;z-index: 9999;}
	.hb4{width:100%;position: absolute;top:58%;text-align: center;font-size: 1.2rem;color:#fff;font-weight: 600;}
	.hb3 text{font-size:1.9rem!important;}
	.hb3{width:100%;position: absolute;top:3%;text-align: center;font-size: 4.5rem;color:#fa1d2c;font-weight: 600;}
	.hb{width:90%;}
	.hongbao{width:100%;text-align: center;margin-top: 30px;position: relative;z-index: 9999;}
	.beijing{width:100%;position: fixed;top:0px;}
	page{background-color: #fadfaa;}
</style>
